﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace SongSharp.Logging
{
    public class Logger
    {
        public class LogInfo : INotifyPropertyChanged
        {
            private static LogInfo ms_instance;
            private LogInfo() { }

            public static LogInfo Instance
            {
                get
                {
                    if (ms_instance == null)
                        ms_instance = new LogInfo();
                    return ms_instance;
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;

            private string m_log;

            public string Log
            {
                get { return m_log; }
                set
                {
                    lock (this)
                    {
                        m_log = value;
                        OnPropertyChanged("Log");
                    }
                }
            }

            protected virtual void OnPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this,
                        new PropertyChangedEventArgs(propertyName));
                }
            }
        }

        private static LogInfo logInfo = LogInfo.Instance;

        public static void Log(string message)
        {
            lock (logInfo)
            {
                logInfo.Log += message + "\n";
            }
        }
    }
}
